//
//  File.swift
//  BasicTools
//
//  Created by S JZ on 2025/5/28.
//

import Foundation
import SwiftUI

//public struct StorageSize {
//    static var shared: StorageSize = StorageSize()
//    
//    var ScreenWidth: CGFloat = 0
//    var ScreenHeight: CGFloat = 0
//}

extension BasicWrapper where Base: View {
//    @available(iOS 15.0, *)
//    public func fullSize() -> some View {
//        base
//            .overlay {
//            GeometryReader { proxy in
//                StorageSize.shared.ScreenWidth = proxy.size.width
//                StorageSize.shared.ScreenWidth = proxy.size.width
//                return EmptyView()
//            }
//        }
//    }
    
    /**
     * 获取view大小，并以闭包的形式返回给视图
     */
//    @available(iOS 15.0, *)
    public func viewSize(_ size: @escaping (CGSize) -> Void) -> some View {
        base.background(
                GeometryReader(content: { proxy in
                    Color.clear
                        .onAppear { size(proxy.size) }
                        .bt.onChange(of: proxy.size) { newValue in
                            size(proxy.size)
                        }
                })
            )
    }
}


